<!DOCTYPE html>
<html lang="en">

<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/css/common.css">
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-6">
                <h1>《{$region_fname}》的子分类列表</h1>
            </div>
        </div>
        <div class="row">
            <if condition="$region_fid">
                <div class="col-lg-2">
                    <a href="{:U('ReturnP')}?region_fid={$region_fid}">
                        <button class="btn btn-block btn-primary">返回父节点</button>
                    </a>
                </div>
            </if>
            <div class="col-lg-4">
                <button class="btn btn-block btn-primary" onclick="add()">添加《{$region_fname}》的子分类</button>
            </div>

        </div>
        <div class="row">
            <div class="col-lg-12">

                <div class="row">
                    <div class="col-md-12">
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                    <tr>
                                        <th style="text-align: center" width="25%">分类名称</th>
                                        <th style="text-align:center" width="100px">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <foreach name="DATA" item="v" key="k">
                                        <tr class="odd gradeX" id="tr{$v.unid}">
                                            <if condition="$v.region_code eq NULL">
                                                <td>{$v.region_name}</td>
                                                <else/>
                                                <td>{$v.region_name}({$v.region_code})</td>
                                            </if>
                                            <td class="center"   style="text-align:center">
                                                <a class="btn btn-block btn-primary"
                                                   href="{:U('Index')}?region_fid={$v.region_id}&region_fname={$v.region_name}">查看《{$v.region_name}》的子分类</a>
                                                <a class="btn btn-block btn-primary"onclick="updateData('{$v.region_id}','{$v.region_name}','{$v.region_code}')">编辑</a>
                                                <a class="btn btn-block btn-primary"
                                                   href="{:U('Del')}?region_id={$v.region_id}">删除</a>
                                            </td>
                                        </tr>
                                    </foreach>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>

                    </div>
                </div>


            </div>
        </div>

    </div>
</div>


<div id="allayModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">添加分类</h4>
            </div>
            <form id="profitForm" action="{:U('Add')}" method="post" enctype="multipart/form-data">
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-xs-12">
                                <label style="color: red">分类名称(必填)</label>
                                <input type="hidden"  name="region_fid" class="rugby-login form-control"
                                       value="{$region_fid}">
                                <input type="hidden"  id="region_id" name="region_id" class="rugby-login form-control">
                                <input type="text" id="region_name" name="region_name" class="rugby-login form-control">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12">
                                <label>附属CODE(选填)</label>
                                <input type="text" id="region_code" name="region_code" class="rugby-login form-control">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit">
                        确认
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>


<include file="CommonSidebar:common-script"/>
<script src="__ROOT__/Application/Admin/Public/js/jquery.datetimepicker.js"></script>
<!-- DataTables JavaScript -->
<script src="__ROOT__/Application/Admin/Public/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="__ROOT__/Application/Admin/Public/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->


<script type="text/javascript" src="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.js?v=3"></script>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.css" type="text/css"
      media="screen"/>


<script>
    $(document).ready(function () {
        $('#dataTables-example').DataTable({
            responsive: true
        });
    });
</script>
<script>
    function add() {
        $("#allayModal").modal("show");
    }
    //编辑
    function updateData(region_id,region_name,region_code){
        $('#region_id').val(region_id);
        $('#region_name').val(region_name);
        $('#region_code').val(region_code);
        $("#allayModal").modal("show");
    }
</script>
</body>

</html>
